package org.little.v2;

import org.junit.Test;
import org.little.context.ApplicationContext;
import org.little.context.support.ClassPathXmlApplicationContext;
import org.little.service.v2.AccountDao;
import org.little.service.v2.ItemDao;
import org.little.service.v2.PetStoreService;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
 * @author Tinyspot
 * @date 2022-05-21 12:58
 */
public class ApplicationContextTest2 {

    @Test
    public void testGetBeanProperty() {
        ApplicationContext context = new ClassPathXmlApplicationContext("little-v2.xml");
        PetStoreService petStoreService = (PetStoreService) context.getBean("petStore");

        assertNotNull(petStoreService.getAccountDao());
        assertNotNull(petStoreService.getItemDao());
        assertTrue(petStoreService.getAccountDao() instanceof AccountDao);
        assertTrue(petStoreService.getItemDao() instanceof ItemDao);

        assertEquals("xiao", petStoreService.getUserName());
        assertEquals(1, petStoreService.getVersion());
    }
}
